
import { __private, BlockInputEvents, _decorator, Layers, Node, } from "cc";
import { Fragment } from "./Fragment";
import FragmentManager, { AddListener, Layer, RemoveListener } from "../FragmentManager";
import View from "../view/View";

export class PopUpFragment extends Fragment {

    black: BlockInputEvents;

    constructor(layer: Layer, name: string) {
        super(layer, name)
        this.layer = Layers.Enum.UI_2D;
        this.black = this.addComponent(BlockInputEvents);
        this.black.enabled = false;
    }

    async addView(manager: FragmentManager, view: View, listener?: AddListener, params?: any): Promise<Node | null> {
        this.black.enabled = true;
        return super.addView(manager, view, listener, params);
    }

    async removeView(manager: FragmentManager, view: View, destroy?: boolean, listener?: RemoveListener, params?: any): Promise<boolean> {
        const result = await super.removeView(manager, view, destroy, listener, params);
        this.black.enabled = false;
        return Promise.resolve(result);
    }

    clear(manager: FragmentManager, destroy: boolean): void {
        super.clear(manager, destroy)
        this.black.enabled = false;
    }

}


